home *** CD-ROM | disk | FTP | other *** search
- Path: isonews.bbn.hp.com!hpbblb!news
- From: Matthias Dittrich <matti>
- Newsgroups: comp.lang.c
- Subject: Re: Low level reading and writing
- Date: 26 Feb 1996 07:48:27 GMT
- Organization: Hewlett-Packard Co.
- Message-ID: <4grokb$2mv@hpbblb.bbn.hp.com>
- References: <ragnaroek1996Feb22.090723.20448@news2.compulink.com>
- NNTP-Posting-Host: trabant.bbn.hp.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.07 9000/712)
- X-URL: news:ragnaroek1996Feb22.090723.20448@news2.compulink.com
-
- hodges@idirect.com (Hodges@idirect.com) wrote:
- > ...
- >My problem is as follows....
- >
- >The read and write functions only return the number of bytes read or
- >written. So why is it necessary to increment "length++" after using strcpy
- >function to copy "Happy Birthday." to outbuffer. By doing this, length
- >actually returns the byte size including the NULL character. ?????
- >
- This is correct. The '\0' character has been written to your file. If you
- are reading your file, you will get it. So you get a correctly terminated
- c-string.
-
- >
- >Question # 2:
- >
- >In standard I/O, the fprintf function can be used to write formatted output
- >to a file associated with a file pointer. Can sprintf be used with Low level
- >I/O to write formatted output to a file associated with a specific file
- >handle? If not how would one go about writing to a low level file which
- >would achieve the same results as fprintf does with Standard I/O?
- > ...
- The usage is the same as in your code. The function sprintf fills a buffer
- with your string. Use outbuffer for this and call write in the same way.
- Your problem is in both cases to ensure not to cross the buffers boundaries.
-
- Good luck,
- Matthias
-
-